<?php
namespace app\common\validate;

use think\Validate;

class ConfigValidate extends Validate
{
    protected $rule =   [
        'name'  => 'require|max:25|unique:config',
        'title'  => 'require|max:25|unique:config',
        'remark' => 'require|max:200',
		'type_id'	=> 'require|number',
		'group_id'	=> 'require|number',
		'sort'	=> 'require|number'
    ];
    
    protected $message  =   [
        'name.require' => '名称必须填写',
        'name.max'     => '名称最多不能超过25个字符',
        'name.unique'     => '配置项名称不能重复',
		'title.require' => '中文名称必须填写',
        'title.max'     => '中文名称最多不能超过25个字符',
        'title.unique'     => '配置项中文名称不能重复',
        'remark.require'=> '描述必须填写',
        'remark.max'  => '描述最多不能超过200个字符',
		'type_id.require' => '必须选择类型',
		'type_id.number' => '必须选择类型为数字',
		'group_id.require' => '必须设置分组',
		'group_id.number' => '必须设置分组为数字',
		'sort.require' => '必须输入排序',
		'sort.number' => '必须输入数字'
    ];
    
    protected $scene = [
        'add'  =>  ['name','title','remark','type_id','group_id','sort'],
        'edit'  =>  ['name','title','remark','type_id','group_id','sort'],
		'sort' => ['sort']
    ];
}
